package com.aspose.cells;

import java.util.ArrayList;

class zanl {
   private ArrayList a = new ArrayList();
   private com.aspose.cells.b.a.d.zn b = null;
   private Encoding c = null;
   private String d = "Content-Location";
   private String e = "Content-Transfer-Encoding";
   private String f = "Content-Type";
   private String g = "Content-ID";
   private String h = "boundary=";
   private String i = "X-Document-Type";
   private static final com.aspose.cells.b.c.a.za j = new com.aspose.cells.b.c.a.za(new String[]{"7bit", "8bit", "binary", "quoted-printable", "base64", "x-encodingname"});

   public ArrayList a(com.aspose.cells.b.a.d.zm var1, Encoding var2) throws Exception {
      this.c = var2;
      this.b = new com.aspose.cells.b.a.d.zn(var1, var2);

      try {
         this.a();
         ArrayList var3 = this.a;
         return var3;
      } finally {
         ;
      }
   }

   public ArrayList a(String var1, Encoding var2) throws Exception {
      this.c = var2;
      this.b = new com.aspose.cells.b.a.d.zn(var1, var2);

      ArrayList var3;
      try {
         this.a();
         var3 = this.a;
      } finally {
         if (this.b != null) {
            this.b.a();
         }

      }

      return var3;
   }

   private void a() throws Exception {
      Object var1 = null;

      while(this.b.c() != -1) {
         String var2 = this.b.f();
         int var3 = var2.indexOf(this.i);
         if (var3 != -1) {
            String var4 = var2.substring(this.i.length() + 1);
            if (var4.trim().toUpperCase().equals("WORKSHEET")) {
               this.b((String)null);
               return;
            }
         } else {
            int var6 = var2.indexOf(this.h);
            if (var6 > -1) {
               String var5 = var2.substring(var2.indexOf(this.h) + this.h.length());
               if (var5.startsWith("\"") && var5.endsWith("\"")) {
                  var5 = var5.substring(1, 1 + (var5.length() - 2));
               }

               var5 = "--" + var5;
               this.a(var5);
            }
         }
      }

   }

   private void a(String var1) throws Exception {
      label23:
      while(true) {
         if (this.b.c() != -1) {
            String var2 = this.b.f();

            while(true) {
               if (var2 == null || !var2.startsWith(var1)) {
                  continue label23;
               }

               if (var2.endsWith("--")) {
                  return;
               }

               var2 = this.b(var1);
            }
         }

         return;
      }
   }

   private String b(String var1) throws Exception {
      com.aspose.cells.b.a.d.zo var2 = null;
      com.aspose.cells.b.a.d.zh var3 = null;
      var3 = new com.aspose.cells.b.a.d.zh();
      var2 = new com.aspose.cells.b.a.d.zo(var3);
      String var4 = null;
      String var5 = null;
      String var6 = null;
      String var7 = null;
      String var8 = null;
      String var9 = null;
      String var10 = null;
      int var11 = 0;
      boolean var12 = false;

      while(this.b.c() != -1) {
         var8 = this.b.f();
         var9 = var8.trim();
         if (var12) {
            if (var9 != null && !"".equals(var9)) {
               if (var1 != null && var9.startsWith(var1)) {
                  break;
               }

               var2.c(var8);
            } else {
               var2.f();
            }
         } else {
            ++var11;
            if (var9 != null && !"".equals(var9)) {
               int var13 = var9.indexOf(this.h);
               if (var13 > -1) {
                  String var16 = var9.substring(var9.indexOf(this.h) + this.h.length());
                  if (var16.startsWith("\"") && var16.endsWith("\"")) {
                     var16 = var16.substring(1, 1 + (var16.length() - 2));
                  }

                  var16 = "--" + var16;
                  this.a(var16);
                  return null;
               }

               if (var1 != null && var9.startsWith(var1)) {
                  break;
               }

               if (var9.startsWith(this.d)) {
                  var4 = zamm.a(var9);
               } else if (var9.startsWith(this.g)) {
                  var5 = zamm.a(var9);
               } else if (var9.startsWith(this.f)) {
                  String[] var14 = com.aspose.cells.b.a.zv.d(var9, ';');
                  var6 = zamm.a(var14[0]);
                  if (var14.length > 1 && var14[1].indexOf("charset=") != -1) {
                     var7 = var14[1].substring("charset=".length()).trim();
                  }
               } else if (var9.startsWith(this.e)) {
                  var10 = zamm.a(var9);
               } else if (var11 > 3) {
                  var2.c(var8);
                  var12 = true;
               }
            }
         }
      }

      var2.c();
      var3.b(0L);
      com.aspose.cells.b.a.d.zm var15 = this.a(var3, var10, this.c);
      if (var15 != null) {
         zank var17 = new zank();
         var17.c = var6;
         var17.a = var4;
         var17.d = var7;
         var17.b = var15;
         com.aspose.cells.b.a.a.ze.a(this.a, (Object)var17);
      }

      return var9;
   }

   private com.aspose.cells.b.a.d.zm a(com.aspose.cells.b.a.d.zm var1, String var2, Encoding var3) throws Exception {
      Object var4 = null;
      switch(j.a(var2)) {
      case 0:
      case 5:
      default:
         break;
      case 1:
      case 2:
         byte[] var7 = com.aspose.cells.a.c.zw.a(var1, false);
         var4 = new com.aspose.cells.b.a.d.zh(var7);
         break;
      case 3:
         var4 = zavx.b(var1, var3);
         break;
      case 4:
         com.aspose.cells.b.a.d.zn var5 = new com.aspose.cells.b.a.d.zn(var1, var3);
         byte[] var6 = com.aspose.cells.b.a.ze.b(var5.e());
         var4 = new com.aspose.cells.b.a.d.zh(var6);
      }

      return (com.aspose.cells.b.a.d.zm)var4;
   }
}
